package vip.xiaonuo.smzq.modular.kcl.controller;

import javax.annotation.Resource;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import vip.xiaonuo.smzq.modular.kcl.entity.Zb;
import vip.xiaonuo.smzq.modular.kcl.entity.vo.Coordinates;
import vip.xiaonuo.smzq.modular.kcl.service.IZbService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.validation.annotation.Validated;
import vip.xiaonuo.common.pojo.CommonResult;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;


/**
 * 坐标
 *
 * @author eomer
 * @since 2024-02-22
 */
@Api(tags = "坐标")
@RestController
@RequestMapping("/kcl/zb")
@Validated
public class ZbController {

    @Resource
    private IZbService iZbService;

    /**
     * 添加坐标
     */
    @ApiOperation("添加坐标")
    @PostMapping("/add")
    public CommonResult<String> add(@RequestBody @Valid Zb zb) {
        iZbService.save(zb);
        return CommonResult.ok();
    }
    /**
     * 添加坐标
     */
    @ApiOperation("添加坐标系")
    @PostMapping("/addCoordinates")
    public CommonResult<String> add(@RequestBody @Valid Coordinates coordinates) {
        //添加坐标
        int zbCount=  iZbService.addZb(coordinates);
        return CommonResult.ok();
    }

    /**
     * 删除坐标
     */
    @ApiOperation("删除坐标")
    @PostMapping("/delete")
    public CommonResult<String> delete(@ApiParam(name = "pkid", value = "主键") @RequestParam String pkid) {
        iZbService.removeById(pkid);
        return CommonResult.ok();
    }

    /**
     * 编辑坐标
     */
    @ApiOperation("编辑坐标")
    @PostMapping("/edit")
    public CommonResult<String> edit(@RequestBody @Valid Zb zb) {
        iZbService.updateById(zb);
        return CommonResult.ok();
    }

    /**
     * 坐标分页查询
     */
    @ApiOperation("坐标分页查询")
    @GetMapping("/list")
    public CommonResult<Page<Zb>> page() {
        return CommonResult.data(iZbService.page(new Zb()));
    }


    /**
     * 勘查区块范围，资源储量计算范围的拐点坐标，标高，面积及示意图
     * @Param kqbm 矿区编码
     * @Param djflbm 登记分类编码
     * @Param nd 年度
     */
    @ApiOperation("勘查区块范围，资源储量计算范围的拐点坐标，标高，面积及示意图")
    @GetMapping("/getCoordinates")
    public CommonResult<Coordinates> getCoordinates(
            @ApiParam(name = "kqbm", value = "矿区编码",  required = true) @RequestParam String kqbm,
            @ApiParam(name = "djflbm", value = "登记分类编码",  required = true) @RequestParam Integer djflbm,
            @ApiParam(name = "nd", value = "年度",  required = true) @RequestParam Integer nd
    ) {
        return CommonResult.data(iZbService.getCoordinates(kqbm,djflbm,nd));
    }






}
